
app.controller('dishCtrl',function($scope,$http){
	$scope.dishletter=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
	
     $scope.data=[];
	 for(var i=0;i<26;i++){
	 	$http.get('../php/dish.php?listorder='+$scope.dishletter[i]).success(function(DD){	
//			$scope.X =data ;
			$scope.data.push(DD)
		});
	 }
	 //点击事件
	 $('.d_bar li').each(function(i,e){
	 	$(e).on('touchstart',function(){
	 		$('.d_contentLet').each(function(index,el){
	 			if($(e).html()==$(el).html()){
	 				//上色
	 			$('.d_bar li').css('color','red')	
	 			$(e).css('color','lightgray')
	 			//跳转
	 			var cHeight=$(el).offset().top;
	 			$('body').animate({
	 				scrollTop:cHeight
	 			},500,function(){
//	 				console.log($(el).scrollTop())
	 			})
	 			}
	 		})

	 	})	
	 })
 
    //滚动变色事件
    document.body.ontouchmove = function(){
    	$('.d_contentLet').each(function(index,el){
    	var m = $(el).offset().top-$('body').scrollTop()
    		if(m>=-100&&m<=100){
    		$('.d_bar li').css('color','red')	
    		$('.d_bar li').eq(index).css('color','lightgray')
    		}
    	}) 	
   } 	
})
